﻿using System;
using System.Text;

namespace Demo
{
    class Program
    {
        #region 常量

        //const int PRICE1 = PRICE2 * 2;
        //const int PRICE2 = 368;

        //static readonly int PRICE3 = PRICE4 * 2;
        //static readonly int PRICE4 = 368;

        //const double PI = 3.1415926;
        //static double R;
        #endregion
        #region 数据类型-引用

        //static Consume consume = new Consume();

        #endregion
        static void Main()
        {
            #region 数据类型——引用类型

            /* 
            * object类 = System.Object
            * object是所有类的基类
            * string类 = System.String
            * 最主要的作用：简化字符串操作
            * 
            */

            //object o1 = 4;
            //int i = 5;

            //consume.Record();

            #endregion
            #region 常量

            //const double PI = 3.1415926;
            //double R;

            //Console.WriteLine("请输入圆的半径");
            //R = Convert.ToDouble(Console.ReadLine());

            //Console.WriteLine("这个圆的面积是：{0}",PI * (R * R));

            //Console.WriteLine(PRICE1);
            //Console.WriteLine(PRICE2);
            //Console.WriteLine(PRICE3);
            //Console.WriteLine(PRICE4);
            #endregion
            #region 运算符

            //int C = 89;
            //int CS = 60;
            //int SQL = 90;
            //Console.WriteLine("C:{0}",C);
            //Console.WriteLine("CS:{0}",CS);
            //Console.WriteLine("SQL:{0}\n",SQL);

            //Console.WriteLine("CS和SQL分数差:{0}",CS > SQL?CS - SQL:SQL - CS);
            //Console.WriteLine("平均成绩{0}",(C + CS + SQL) / 3);

            //int i = 368;
            //int j = 0;
            //Console.WriteLine(i / j);

            //double i = -6.5;
            //int j = -2;
            //double result = i % j;
            //Console.WriteLine(result);// -0.5 取模时看左边有无符号

            //Console.WriteLine("请输入用户名：");
            //string username = Console.ReadLine();
            //Console.WriteLine("请输入用户密码：");
            //string userpassword = Console.ReadLine();

            //if (username == "Q" && userpassword == "123456")
            //{
            //    Console.WriteLine("登入成功!");
            //}
            //else
            //{
            //    Console.WriteLine("登入失败!");
            //}

            //Console.WriteLine(12 & 2);

            //Console.WriteLine("请输入密码: ");
            //int pwd = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("请输入加密密钥: ");
            //int key = Convert.ToInt32(Console.ReadLine());
            //int pwdkey = ~pwd;
            //Console.WriteLine(~pwdkey);

            //Console.WriteLine(48 << 1);
            //Console.WriteLine(48 << 2);
            //Console.WriteLine(48 >> 1);
            //Console.WriteLine(48 >> 2);
            //Console.WriteLine(-80 >> 2);

            //Console.WriteLine(2 << 1);



            #endregion
            #region 字符串

            //string str = "时间就是金钱";

            //char[] ch01 = { 'H', 'e', 'l', 'l', 'o' };
            //string str02 = new string(new char[]{ 'H', 'e', 'l', 'l', 'o' });

            //Console.WriteLine(str02,4,2);

            //string str1 = "";
            //string str2 = null;

            //Console.WriteLine(str1.ToString());
            //Console.WriteLine(str2.ToString());

            //string name = "Tom";
            //string dbValue = "tom";

            //Console.WriteLine(!Convert.ToBoolean(String.Compare(name,dbValue)));

            //Console.WriteLine(string.Format("金额显示: {0:c}",368));
            //Console.WriteLine(string.Format("金额显示: {0:c0}", 368));
            //Console.WriteLine(string.Format("科学计数法: {0:e}", 12000.1));
            //Console.WriteLine(string.Format("分割数字显示: {0:n}", 1234567890));
            //Console.WriteLine(string.Format("分割数字显示: {0:n0}", 1234567890));
            //Console.WriteLine(string.Format("π取两位小数显示: {0:f2}", Math.PI));
            //Console.WriteLine(string.Format("十六进制显示: {0:x}", 33));
            //Console.WriteLine(string.Format("十六进制显示: {0:x4}", 33));
            //Console.WriteLine(string.Format("百分比显示: {0:p}", 0.99));
            //Console.WriteLine(string.Format("百分比显示: {0:p0}", 0.99));

            //DateTime time = DateTime.Now;
            //Console.WriteLine(string.Format("短日期格式: {0:d}",time));
            //Console.WriteLine(string.Format("长日期格式: {0:D}", time));
            //Console.WriteLine(string.Format("完整日期格式: {0:f}", time));
            //Console.WriteLine(string.Format("短时间格式: {0:t}", time));
            //Console.WriteLine(string.Format("长时间格式: {0:T}", time));
            //Console.WriteLine(string.Format("月日格式: {0:M}", time));
            //Console.WriteLine(string.Format("年月期格式: {0:Y}", time));

            //Console.WriteLine(time.ToString("Y"));
            //int i = 98;
            //Console.WriteLine(i.ToString("C0"));

            //string fileName = "Program.cs.cs.cs.cs.cs";
            ////string strName = fileName.Substring(0, fileName.IndexOf("."));
            ////string strExtension = fileName.Substring(fileName.IndexOf("."));

            ////Console.WriteLine("FileName = {0}",strName);
            ////Console.WriteLine("FileExtension = {0}",strExtension);

            //string[] strs = fileName.Split(new char[] { '.' },10);
            //foreach (string item in strs)
            //{
            //    Console.WriteLine(item);
            //}

            //string strOld = "Keep on never give up";
            //string strNew = strOld.Insert(8, "going ");
            //Console.WriteLine(strNew);

            //string strOld = "Keep on going never give up";
            //string strNew1 = strOld.Remove(7);
            //string strNew2 = strOld.Remove(7, 6);

            //Console.WriteLine(strNew1);
            //Console.WriteLine(strNew2);

            //string strOld = "Keep on going never give up";
            //string strNew = strOld;

            //Console.WriteLine(strOld);
            //Console.WriteLine(strNew);

            //string str = "馒头一文一个";
            //string replaceStr = str.Replace('一', '壹');
            //string str1 = str.Replace("馒头", "馍馍");

            //Console.WriteLine(replaceStr);
            //Console.WriteLine(str1);

            //StringBuilder sTitle = new StringBuilder("(),(),(),2、4、6、7、8");
            //Console.WriteLine(sTitle);
            //sTitle.Remove(0, 9);
            //sTitle.Insert(0, "(门前大桥下),(游过一群鸭),(快来快来数一数),");
            //Console.WriteLine(sTitle);

            //string str = "";
            //long startTime = DateTime.Now.Millisecond;
            //for (int i = 0; i < 10000; i++)
            //{
            //    str += i;
            //}
            //long endTime = DateTime.Now.Millisecond;
            //long time = endTime - startTime;

            //Console.WriteLine(startTime);
            //Console.WriteLine(endTime);
            //Console.WriteLine(time);//30

            //StringBuilder s = new StringBuilder("");
            //startTime = DateTime.Now.Millisecond;
            //for (int i = 0; i < 10000; i++)
            //{
            //    s.Append(i);
            //}
            //endTime = DateTime.Now.Millisecond;
            //time = endTime - startTime;
            //Console.WriteLine(startTime);
            //Console.WriteLine(endTime);
            //Console.WriteLine(time);


            #endregion
            #region if语句

            //Console.WriteLine("请输入一个整数");
            //int input = Convert.ToInt32(Console.ReadLine());

            //if(input % 2 == 0)
            //{
            //    Console.WriteLine(input);
            //}

            //Console.WriteLine("请输入一个数字");

            //int input = Convert.ToInt32(Console.ReadLine());

            //if (input % 2 == 0)
            //{
            //    Console.WriteLine("是偶数");
            //}
            //else
            //{
            //    Console.WriteLine("是奇数");
            //}

            //Console.WriteLine("请输入银行的简称(ICBC,CBC,ABC)");

            //string str = Console.ReadLine();

            //if(str == "ICBC")
            //{
            //    Console.WriteLine("中国工商银行");
            //}
            //else if (str == "CBC")
            //{
            //    Console.WriteLine("中国建设银行");
            //}
            //else if(str == "ABC")
            //{
            //    Console.WriteLine("中国农业银行");
            //}
            //else
            //{
            //    Console.WriteLine("输入银行简称错误");
            //}

            #endregion
            #region switch多分支语句

            //Console.WriteLine("请输入要查询的录取分数线(名办本科、艺术类本科、体育类本科、二本、一本): ");
            //string str = Console.ReadLine();

            //switch (str)
            //{
            //    case "ICBC":
            //    case "icbc":
            //        Console.WriteLine("中国工商银行");
            //        break;
            //    case "CBC":
            //    case "cbc":
            //        Console.WriteLine("中国建设银行");
            //        break;
            //    case "ABC":
            //    case "abc":
            //        Console.WriteLine("中国农业银行");
            //        break;
            //    default:
            //        Console.WriteLine("输入简称有误");
            //        break;
            //}

            //Console.WriteLine("请输入要查询的录取分数线(名办本科、艺术类本科、体育类本科、二本、一本): ");
            ////string str = Console.ReadLine();
            //string input = Console.ReadLine();

            //switch (input.ToString())
            //{
            //    case "名办本科":
            //        Console.WriteLine("名办本科的录取分数线是350");
            //        break;
            //    case "艺术类本科":
            //        Console.WriteLine("艺术类本科的录取分数线是290");
            //        break;
            //    case "体育类本科":
            //        Console.WriteLine("体育类本科的录取分数线是280");
            //        break;
            //    case "二本":
            //        Console.WriteLine("二本的录取分数线是445");
            //        break;
            //    case "一本":
            //        Console.WriteLine("一本的录取分数线是555");
            //        break;
            //    default:
            //        Console.WriteLine("重考");
            //        break;
            //}

            #endregion
            #region while循环

            //int sum = 0;
            //int i = 1;

            //while(i <= 100)
            //{
            //    sum += i;
            //    i++;
            //    Console.WriteLine(sum);
            //}

            #endregion
            #region do……while循环

            //int i = 1;
            //int sum = 0;

            //do
            //{
            //    sum += i;
            //    i++;
            //    Console.WriteLine(sum);
            //} while (i <= 100);

            //string firstPwd;
            //string secondPwd;

            //do
            //{
            //    Console.WriteLine("请输入密码");
            //    firstPwd = Console.ReadLine();
            //    Console.WriteLine("请再次输入密码");
            //    secondPwd = Console.ReadLine();

            //} while (firstPwd != secondPwd);


            #endregion
            #region for循环

            //int sum = 0;

            //for (int i = 1; i <= 100;i++)
            //{
            //    Console.WriteLine(sum += i);
            //}

            //for (; ; )
            //{
            //    Console.WriteLine("请输入用户名");
            //    Console.ReadLine();
            //}





            #endregion
            #region 数组

            int[] a = new int[] {100,3,4,7,83,645,2342,534,22,43,213,123,123,1,23,123,123,123,113183,123,13,123,12,3,446,546,6,456,56,54};
            int max = 0;
            for(int i = 0;i < a.Length; i++)
            {
                for(int j = 0; j < a.Length; j++)
                {
                    if(max < a[j])
                    {
                        max = a[j];
                    }
                }
            }

            Console.WriteLine(max);

            #endregion

            Console.Read();
        }

    }

    #region 数据类型-引用

    //class Card
    //{
    //    public string Money { get; set; }
    //}

    //class Consume
    //{
    //    public void Record()
    //    {
    //        Console.WriteLine("行用卡消费记录\n");
    //        Card pCard = new Card() { Money = "8000"};
    //        Console.WriteLine("信用卡的总额度：" + pCard.Money);
    //        Card sCard = pCard;
    //        sCard.Money = "3000";
    //        Console.WriteLine("信用卡消费记录：" + pCard.Money);
    //    }
    //}

    #endregion

}